﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>预约记录详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="//unpkg.com/layui@2.11.0/dist/css/layui.css" rel="stylesheet">
    <style>
        .navbar {
            display: none;
        }
    </style>

</head>
<body>
    <div class="layui-card">
        <div class="layui-card-header">
            <h2>患者信息</h2>
        </div>
        <div class="layui-card-body">
            <table class="layui-table">
                <colgroup>
                    <col width="150">
                    <col width="200">
                    <col width="150">
                    <col width="200">
                    <col width="150">
                </colgroup>
                <tr>
                    <td>患者姓名</td>
                    <td id="patientName"></td>
                    <td>就诊卡号</td>
                    <td id="patientNo"></td>
                </tr>
                <tr>
                    <td>证件类型</td>
                    <td>身份证</td>
                    <td>证件号码</td>
                    <td id="documentNo"></td>
                </tr>
                <tr>
                    <td>手机号码</td>
                    <td id="phone">
                    </td>
                </tr>
                
            </table>
        </div>
    </div>

    <div class="layui-card" style="margin-top: 20px;">
        <div class="layui-card-header">
            <h2>预约信息</h2>
        </div>
        <div class="layui-card-body">
            <table class="layui-table">
                <colgroup>
                    <col width="150">
                    <col width="300">
                    <col width="150">
                    <col width="300">
                </colgroup>
                <tr>
                    <td>就诊医院</td>
                    <td id="campusName"></td>
                    <td>医院地址</td>
                    <td id="addressCampus"></td>
                </tr>
                <tr>
                    <td>就诊科室</td>
                    <td id="deparName"></td>
                    <td>就诊医生</td>
                    <td id="doctorName"></td>
                </tr>
                <tr>
                    <td>医生职称</td>
                    <td id="jobName"></td>
                    <td>挂号类型</td>
                    <td id="registrationType"></td>
                </tr>
                <tr>
                    <td>门诊时间</td>
                    <td id="mtime"></td>
                    <td>就诊时间</td>
                    <td id="waitTime"></td>
                </tr>
                <tr>
                    <td>挂号费</td>
                    <td id="registrationfee"></td>
                    <td>预约时间</td>
                    <td id="registrationTime"></td>
                </tr>
                <tr>
                    <td>就诊状态</td>
                    <td id="statue"></td>
                    <td>取消原因</td>
                    <td id="updateReson"></td>
                </tr>
                <tr>
                    <td>取消时间</td>
                    <td id="updateTime"></td>
                    
                </tr>
            </table>
        </div>
    </div>

    
          

    <script src="//unpkg.com/layui@2.11.0/dist/layui.js"></script>

    <script>
       
        layui.use(['form', 'layer'], function () {
            var form = layui.form;
            var layer = layui.layer;
            var $ = layui.$;

            // 使用URLSearchParams API
            var urlParams = new URLSearchParams(window.location.search);
            var registrationId = urlParams.get('registrationId') || 0;

        
            function getregistration() {
                $.ajax({
                    url: `@ViewBag.BaseUrl/T5/Registration/QueryRegistration?RegistrationId=${registrationId}`,
                    success: function (res) {
                        var data  = res.data;
                        // 患者信息部分
                        $('#campusName').html(data.campusName || '');
                        $('#addressCampus').html(data.addressCampus || '');
                        $('#patientName').html(data.patientName || '');
                        $('#patientNo').html(data.patientNo || '');
                        $('#documentNo').html(data.documentNo || '');
                        $('#phone').html(data.phone || '');

                        // 预约信息部分
                        $('#deparName').html(data.deparName || '');
                        $('#doctorName').html(data.doctorName || '');
                        $('#jobName').html(data.jobName || '');
                        $('#registrationfee').html(data.registrationfee ? '¥' + parseFloat(data.registrationfee).toFixed(2) : '¥0.00');
                        $('#doctorlocation').html(data.doctorlocation || '');
                        $('#registrationType').html(data.registrationType || '');
                        $('#statue').html(data.statue || '');
                        $('#registrationTime').html(formatDateTime(data.registrationTime));
                        $('#mtime').html(data.mtime);
                        $('#waitTime').html(data.waitTime || '');
                        $('#updateTime').html(formatDateTime(data.updateTime));
                        $('#updateReson').html(data.updateReson || '');
                    }
                });
            }
                getregistration()
            function formatDateTime(dateStr) {
                if (!dateStr) return '';

                try {
                    const date = new Date(dateStr);
                    return date.toLocaleString(); // 或者使用更具体的格式如：formatDate(date)
                } catch (e) {
                    return dateStr; // 如果无法解析，返回原始字符串
                }
            }

            // 更详细的日期格式化函数（可选）
            function formatDate(date) {
                const year = date.getFullYear();
                const month = String(date.getMonth() + 1).padStart(2, '0');
                const day = String(date.getDate()).padStart(2, '0');
                const hours = String(date.getHours()).padStart(2, '0');
                const minutes = String(date.getMinutes()).padStart(2, '0');

                return `${year}-${month}-${day} ${hours}:${minutes}`;
            }
            })
        

    </script>


</body>
</html>
